import Vue from 'vue'
import router from './router'
import axios from 'axios'
import NProgress from 'nprogress'
// import ElementUI from 'element-ui'
import Moment from 'moment'
import VueQuillEditor from 'vue-quill-editor'
import TreeTable from 'vue-table-with-tree-grid'

import App from './App'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'

// axios
axios.defaults.baseURL = 'http://localhost:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  NProgress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})
Vue.prototype.$http = axios

// element
// Vue.use(ElementUI) // 全局注册所有组件
// Vue.prototype.$message = ElementUI.Message
// Vue.prototype.$confirm = ElementUI.MessageBox.confirm

// moment
Vue.filter('formatTime', (data, formatStr) => Moment(data).format(formatStr || 'YYYY-MM-DD HH:mm:ss'))

// vue-quill-editor
Vue.use(VueQuillEditor)

// vue-tree-table-with-tree-grid
Vue.component('tree-table', TreeTable)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
  render: h => h(App) // 使用 element-ui
})
